//
//  FANStatus.swift
//  Weibo - Swift
//
//  Created by user on 16/4/20.
//  Copyright © 2016年 user. All rights reserved.
//

import UIKit

class FANStatus: NSObject {
        
    var id:Int64 = 0
    
    var text:String?
    
    var created_at:String?
    
    var source:String?
    
    var user:FANUser?
    
    var retweeted_status:FANStatus?
    
    var pic_urls :[FANStatusPicInofo]?
    
    init(dict:[String:AnyObject]) {
        
        super.init()
        
        setValuesForKeysWithDictionary(dict)
    }
    
    
    override func setValue(value: AnyObject?, forKey key: String) {
        
        if key == "user" {
            
            guard let dict = value as? [String:AnyObject] else{
                
                return
            }
            
            user = FANUser(dict: dict)
            
        }else if key == "retweeted_status"{
            
            guard let dict = value as? [String:AnyObject] else{
                
                return
            }
            
            retweeted_status = FANStatus(dict: dict)
            
        }else if key == "pic_urls" {
            
            guard let values = value as? [[String:AnyObject]] else{
                
                return
            }
            
            var tempArray:[FANStatusPicInofo] = [FANStatusPicInofo]()
            
            for value in values{
                
                let info = FANStatusPicInofo(dict: value)
                
                tempArray.append(info)
            }
            
            pic_urls = tempArray
            
        }
        else{
            
            super.setValue(value, forKey: key)
        }
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {}

}
